class Solution {
    int dx[8] = { 0, 0, 1, -1 };
    int dy[8] = { 1, -1, 0, 0 };
public:
    vector<vector<int> > flipChess(vector<vector<int> >& A, vector<vector<int> >& f) {
        for (auto v : f)
        {
            int i = v[0] - 1, j = v[1] - 1;
            for (int k = 0; k < 4; k++)
            {
                int x = i + dx[k], y = j + dy[k];
                if (x >= 0 && x < 4 && y >= 0 && y < 4)
                {
                    if (A[x][y] == 1) A[x][y] = 0;
                    else A[x][y] = 1;
                }
            }
        }

        return A;
    }
};